<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>星调查问卷系统</title>

<!-- BOOTSTRAP STYLES-->
<link href="css/bootstrap.css" rel="stylesheet" />
<!-- FONTAWESOME STYLES-->
<link href="css/font-awesome.css" rel="stylesheet" />
   <!--CUSTOM BASIC STYLES-->
<link href="css/basic.css" rel="stylesheet" />
<!--CUSTOM MAIN STYLES-->
<link href="css/custom.css" rel="stylesheet" />
<!-- GOOGLE FONTS-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
<link rel="stylesheet" href="css/bootstrapValidator.css">
</head>
<body>
<div id="wrapper">
    <nav class="navbar navbar-default navbar-cls-top " role="navigation" style="margin-bottom: 0">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="home.jsp">星调查问卷系统</a>
        </div>

    </nav>
    <!-- /. NAV TOP  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">
                <li>
                    <div class="user-img-div">
                            <c:if test="${sessionScope.users.user_photo==null }">
                             <img src="images/user.png" class="img-thumbnail" />
                        </c:if> 
                        <c:if test="${sessionScope.users.user_photo!=null }">
                                <img src="${pageContext.request.contextPath}/images/user/${sessionScope.users.user_name}.${sessionScope.users.user_photo}" class="img-thumbnail">
                        </c:if> 
                        <div class="inner-text">
                            <span>${sessionScope.users.user_name }</span>
                        <br />
                            <small>
                                    用户级别：
                                    <c:if test="${sessionScope.users.user_root==1 }">
                                        管理员
                                </c:if> 
                                <c:if test="${sessionScope.users.user_root==0}">
                                        普通用户
                                </c:if> 
                                <form action="${pageContext.request.contextPath}/outLogin.do">
                                    <table>
                                        <tr>
                                            <td><input type="submit" value="退出登录" class="form-control input-sm"></td>
                                        </tr>
                                    </table>
                                </form>
                            </small>
                        </div>
                    </div>

                </li>


                <li>
                    <a href="${pageContext.request.contextPath}/home.do"><i class="fa fa-dashboard "></i>我的问卷</a>
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/newSurveyView.do"><i class="fa fa-flash "></i>新建问卷</a>           
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/allSurvey.do"><i class="fa fa-flash "></i>所有问卷</a>           
                </li>
                <c:if test="${sessionScope.users.user_root==1 }">
	                <li>
	                    <a class="active-menu" href="${pageContext.request.contextPath}/adminView.do"><i class="fa fa-flash "></i>用户管理</a>           
	                </li>
                </c:if>
                            
            </ul>

        </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                    <h1 class="page-head-line">用户管理</h1>
                </div>
            </div>
            <!-- /. ROW  -->
            <div class="row">
            		 <div class="col-md-5">
            		 	<a data-toggle="modal" data-target="#confirm-delete"><button class="btn btn-primary" id="deletConfirm"  data-toggle="modal" data-target='#myModal'>添加用户</button></a>
                                		  <div class="modal fade" id='myModal' tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                            <div class="modal-dialog" role="document">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                            <span aria-hidden="true">&times;</span>
                                                        </button>
                                                        <h4 class="modal-title">添加用户</h4>
                                                    </div>
                                                    <div class="modal-body">
                                                        <form id="sign" action="${pageContext.request.contextPath}/adminSign.do" class="fh5co-form animate-box"
															data-animate-effect="fadeIn" enctype="multipart/form-data" method="post">
															<h2>注册</h2>
															<div class="form-group">
																<label for="name" class="sr-only">用户名</label> 
																<input type="text" class="form-control" name="user_name" id="user_name" placeholder="用户名" autocomplete="off" datatype="*" nullmsg="请输入用户名！">
															</div>
															<div class="form-group">
																<label for="email" class="sr-only">年龄</label> 
																<input type="text" class="form-control" name="user_age" id="user_age" placeholder="年龄" autocomplete="off" datatype="n" nullmsg="请输入年龄！">
															</div>
															<div class="form-group">
																<label for="password" class="sr-only">密码</label> 
																<input type="password" class="form-control" name="user_password" id="user_password" placeholder="密码" autocomplete="off" datatype="*" nullmsg="请输入密码！">
															</div>
															<div class="form-group">
																<label for="re-password" class="sr-only">确认密码</label> 
																<input type="password" class="form-control" name="re_user_password" id="re_user_password" placeholder="确认密码" autocomplete="off" datatype="*" nullmsg="请输入确认密码！" recheck="user_password" errormsg="两次密码不一致">
															</div>
															<div class="form-group">
																<label for="re-password" class="sr-only">用户权限</label> 
																<select class="form-control" name="user_root">
																  <option value="0">普通用户</option>
																  <option value="1">管理员</option>
																</select>
															</div>
															<div class="form-group">
																头像：<input type="file" name="photo" id="photo"/><br>
															</div>
														
                                                    </div>
                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                                        <input type="submit" value="注册" class="btn btn-primary">
                                                    	   </form>
                                                    </div>
                                                </div>
                                                <!-- /.modal-content -->
                                            </div>
                                            <!-- /.modal-dialog -->
                                        </div> <!-- /.modal -->
            		 </div>
                    <div class="main-box">
                
                    <c:if test="${users==null }">
                    没有用户！
                    </c:if>
                    <c:if test="${users!=null }">
                    <table class="table table-bordered table-hover table-striped">
                    <tr>
                        <th>用户名</th>
                        <th>用户年龄</th>
                        <th>用户权限</th>
                        <th>操作</th>
                    </tr>
                    <c:forEach items="${users}" var="user">
                        <tr>
                           <td>${user.user_name}</td>
                            <td>${user.user_age}</td>
                            <c:if test="${user.user_root==0 }">
                             <td class="text-primary">普通用户</td>
                        </c:if> 
                        <c:if test="${user.user_root==1 }">
                             <td class="text-danger">管理员</td>
                        </c:if>
                            <td>
                                <a data-href="${pageContext.request.contextPath}/userDelet.do?user_id=${user.user_id}" data-toggle="modal" data-target="#confirm-delete"><button class="btn btn-primary" id="deletConfirm"  data-toggle="modal" data-target='#myModal${user.user_id}'>删除</button></a>
                                		  <div class="modal fade" id='myModal${user.user_id}' tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                            <div class="modal-dialog" role="document">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                            <span aria-hidden="true">&times;</span>
                                                        </button>
                                                        <h4 class="modal-title">确认删除用户？</h4>
                                                    </div>
                                                    <div class="modal-body">
                                                        <p>您确定删除用户:${user.user_name}？</p>
                                                    </div>
                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                                        <a href="${pageContext.request.contextPath}/userDelet.do?user_id=${user.user_id}"><button class="btn btn-primary" >确认</button></a>
                                                    </div>
                                                </div>
                                                <!-- /.modal-content -->
                                            </div>
                                            <!-- /.modal-dialog -->
                                        </div> <!-- /.modal -->
                        </td>
                        </tr>
                        </c:forEach>
                        </c:if> 
                </table>
                </div>
            </div>
            <!-- /. ROW  -->

            
            <!-- /. ROW  -->

            <!--/.Row-->
           
            <!--/.Row-->
           
            <!--/.ROW-->

        </div>
        <!-- /. PAGE INNER  -->
    </div>
    <!-- /. PAGE WRAPPER  -->
</div>
<!-- /. WRAPPER  -->

<!-- /. FOOTER  -->
<!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
<!-- JQUERY SCRIPTS -->
<script src="js/jquery-1.10.2.js"></script>
<!-- BOOTSTRAP SCRIPTS -->
<script src="js/bootstrap.js"></script>
<!-- METISMENU SCRIPTS -->
<script src="js/jquery.metisMenu.js"></script>
   <!-- CUSTOM SCRIPTS -->
<script src="js/custom.js"></script>
<script src="js/Validform_v5.3.2_min.js"></script>
  
  	<script>
		$(document).ready(function() {
			$('#sign').Validform({
				tiptype:3, 
			});
		});
	</script>

</body>
</html>
